package com.oig.sys.base.service.impl;

import com.oig.sys.base.dao.ITbHarborAssociationDao;
import com.oig.sys.base.entity.TbHarborAssociation;
import com.oig.sys.base.service.ITbHarborAssociationService;
import com.oig.sys.base.vo.HarborAssociationVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author alex
 * @ClassName TbHarborAssociationServiceImpl.java
 * @Description 港口映射关联管理impl
 * @createTime 2023/8/29
 */
@Service
public class TbHarborAssociationServiceImpl implements ITbHarborAssociationService {

    private final ITbHarborAssociationDao harborAssociationDao;

    @Autowired
    public TbHarborAssociationServiceImpl(ITbHarborAssociationDao harborAssociationDao) {
        this.harborAssociationDao = harborAssociationDao;
    }

    @Override
    public List<HarborAssociationVo> getAllInfoList(){
        List<HarborAssociationVo> harborAssociationVoList = new ArrayList<>();
        List<TbHarborAssociation> harborAssociationList = harborAssociationDao.getAllList();
        for (TbHarborAssociation harborAssociation : harborAssociationList){
            harborAssociationVoList.add(this.buildVo(harborAssociation));
        }
         return harborAssociationVoList;
    }

    private HarborAssociationVo buildVo(TbHarborAssociation harborAssociation){
        HarborAssociationVo harborAssociationVo = new HarborAssociationVo();
        BeanUtils.copyProperties(harborAssociation, harborAssociationVo);
        return harborAssociationVo;
    }
}
